package edu.hawaii.myisern.action;

import java.io.IOException;
import java.net.MalformedURLException;
import org.junit.Test;
import org.xml.sax.SAXException;
import junit.framework.TestCase;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebResponse;

/**
 * Tests IndexActionBean class
 * 
 * @author Sonwright M. Gomez
 *
 */
public class TestAddCollaborationActionBean extends TestCase {

  /** Get the test host. */
  private String testHost = System.getProperty("test.host");

  /**
   * Tests the Index action action bean.
   * 
   * @throws SAXException if error occurs with xml parser.
   * @throws MalformedURLException if error occurs with URL.
   * @throws IOException if error occurs with IO.
   */
  @Test
  public void testAddCollaboration() throws SAXException, MalformedURLException, IOException {
    WebConversation conversation = new WebConversation();

    String pageTitle = "MyIsern - Add Collaboration";

    String Url = testHost + "myisern-1-red/addCollaboration.jsp";
    WebResponse response = conversation.getResponse(Url);
    assertEquals("Checking addCollaboration.jsp retrieval", pageTitle, response.getTitle());
    
    AddCollaborationActionBean ac = new AddCollaborationActionBean();
    ac.setCollaborationDescription("description");
    ac.setCollaborationName("name");
    ac.setCollaborationOrgs("orgs");
    ac.setCollaborationOutcomes("outcomes");
    ac.setCollaborationTypes("types");
    ac.setCollaborationYears("years");
    ac.setErrorMessage("ERROR");
    assertSame("desc is same", "description", ac.getCollaborationDescription());
    assertSame("name is same", "name", ac.getCollaborationName());
    assertSame("orgs is same", "orgs", ac.getCollaborationOrgs());
    assertSame("outcomes is same", "outcomes", ac.getCollaborationOutcomes());
    assertSame("types is same", "types", ac.getCollaborationTypes());
    assertSame("years is same", "years", ac.getCollaborationYears());
    assertSame("error message same", "ERROR", ac.getErrorMessage());
    
  }
}